package com.googlecode.wheres_my_stuff_okay_potato;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

/**
 * This class pops up a multi-choice list of statuses to filter lists of items
 * by.
 * 
 * @author Jeremy
 * 
 */
@SuppressLint("NewApi")
public class StatusPickerFragment extends DialogFragment {
	private boolean open;

	public Dialog onCreateDialog(Bundle savedInstanceState) {
		AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
		builder.setTitle(R.string.status_picker_title);

		builder.setSingleChoiceItems(R.array.statuses_array, 0,
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						open = (which == 0);
					}
				})
				.setPositiveButton(R.string.submit,
						new DialogInterface.OnClickListener() {
							@Override
							public void onClick(DialogInterface dialog, int id) {
								return;
							}
						})
				.setNegativeButton(R.string.cancel,
						new DialogInterface.OnClickListener() {
							@Override
							public void onClick(DialogInterface dialog, int id) {
								// Do nothing and close the dialog
								return;
							}
						});

		return builder.create();
	}

	public boolean getOpen() {
		return open;
	}
}